package com.spddr.pmos.jpa;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Embeddable;

@Embeddable
public class UnitWaterCostId implements java.io.Serializable {
	private static final long serialVersionUID = 1L;

	private long unit;
	private BigDecimal volume;

	public UnitWaterCostId() {
	}

	public UnitWaterCostId(long unit, BigDecimal volume) {
		this.unit = unit;
		this.volume = volume;
	}

	@Column(name = "unit", nullable = false)
	public long getUnit() {
		return this.unit;
	}

	public void setUnit(long unit) {
		this.unit = unit;
	}

	@Column(name = "volume", nullable = false, precision = 5, scale = 1)
	public BigDecimal getVolume() {
		return this.volume;
	}

	public void setVolume(BigDecimal volume) {
		this.volume = volume;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (unit ^ (unit >>> 32));
		result = prime * result + ((volume == null) ? 0 : volume.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UnitWaterCostId other = (UnitWaterCostId) obj;
		if (unit != other.unit)
			return false;
		if (volume == null) {
			if (other.volume != null)
				return false;
		} else if (!volume.equals(other.volume))
			return false;
		return true;
	}
}